<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <style>
        .span-green{
            color: green;
        }
        .span-red{
            color: red;
        }
    </style>
</head>
<body>
<script src="https://unpkg.com/vue@next"></script>
<div id="app">
    <span :class="classObj">show me</span>
</div>
<script>
    const vueOpt = {
        data(){
            return {
                isGreen: false,
                isRed: true,
            }
        },
        computed:{
            classObj(){
                return {
                    'span-green': this.isGreen,
                    'span-red': this.isRed
                }
            }
        }
    }
    const vm = Vue.createApp(vueOpt).mount('#app')
    setTimeout(()=>{
        vm.$data.isGreen = true;
        vm.$data.isRed = false;
    }, 2000)


</script>
</body>
</html>
